<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>登记</title>
		<link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
		<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
		<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
		<script src="../../../lib/common/jquery.cookie.min.js" charset="utf-8"></script>
		<script src="../../../lib/common/common.js" charset="utf-8"></script>
		<script src="../../../lib/serializejson/jquery.serializejson.js"></script>
	</head>
	<body>

		 <!--条件查询-->
        <fieldset class="layui-elem-field" style="margin-top: 20px;padding: 15px">
            <legend>搜索</legend>
            <form class="layui-form layui-form-pane" >
    		</div>
                <label class="layui-form-label">搜索出库单编号</label>
                <div class="layui-input-inline">
                    <input type="text" id="payId" lay-verify="required" placeholder="出库单编号" autocomplete="off" class="layui-input">
                </div>
                <a class="layui-btn" data-type="reload" id="sou">搜索</a>
            </div>
            </form>
        </fieldset>
        <!--数据表格-->
        <div style="margin:30px">
            <table class="layui-hide" id="test" lay-filter="test"></table>
        </div>
        
       
        
        
        
        
        <script type="text/javascript">
        	 layui.use(['table','jquery','form','upload','laydate'], function() {
                var table = layui.table
                    , layer = layui.layer
                    , form = layui.form
                    , $ = layui.jquery
                    , upload = layui.upload
                    ,laydate=layui.laydate;
                    
                   
                      //渲染
                table.render({
                    elem: '#test' //绑定table表格
                    ,url: api4+'OutBoundRegistration/findPayId' //接口
                    ,page: true //true表示分页
                    ,id:'testReload'
                    ,toolbar: '#toolbarDemo'
                    ,cols: [
                        [
                        	{field:'o1Id', title:'编号', unresize: true, sort: true,align:"center"}
                            ,{field:'o1PayId', title:'出库单号', unresize: true, sort: true,align:"center"}
                            ,{field:'o1Reason', title:'出库理由',align:"center",templet:'#reason'}
                            ,{field:'o1RegisterTime', title: '登记时间',align:"center"}
                            ,{field:'o2Amount', title: '总件数',align:"center"}
                            ,{field:'o2Subtotal', title: '总金额',align:"center"}
                            ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
                        ]
                    ]
                });
                //数据重载 模糊查询
                var $ = layui.$, active = {
                    reload: function(){
                        //获得搜索框
                        var payId = $('#payId');
                        //执行重载
                        table.reload('testReload', {
                            page: {
                                curr: 1 //重新从第 1 页开始
                            }
                            //根据条件查询
                            ,where: {
                                payId:payId.val()
                            }
                        });
                    }
                };

                $('#sou').on('click', function(){
                    var type = $(this).data('type');
                    active[type] ? active[type].call(this) : '';
                });          
                
                   //监听行工具事件 删除与修改
            	table.on('tool(test)', function(obj){
            		  var data = obj.data;
            		    if(obj.event === 'edit'){
            		    	//获得id
            		    	var id=data.o1Id;
            		    	$.ajax({
            		    		type:"post",
            		    		url:api4+"OutBoundRegistration/edit",
            		    		 data:{id:id},//参数
            		    		 success:function(da){
            		    		 	if(da.data>0){
            		    		 		 layer.msg(da.msg, {
                                  		 	time: 200,//1秒关闭（如果不配置，默认是3秒）
                               				}, function(){
                                   			location.reload();
                               			 })
            		    		 	}else{
            		    		 		layer.msg("登记失败");
            		    		 	}
            		    		 }
            		    	});
            		    }
               });
               
               
               });
        </script>
        
        <!--出库原因-->
         <script type="textml" id="reason">
			{{# if(d.o1Reason=='C002-1'){d.o1Reason='生产领料'}}
				{{d.o1Reason}}
			{{# }else if(d.o1Reason='C002-2'){d.o1Reason='赠送'}}
				{{d.o1Reason}}
			{{# }else if(d.o1Reason='C002-3'){d.o1Reason='内部借领'}}
				{{d.o1Reason}}
			{{# }else{d.o1Reason='其他借领'}}
				{{d.o1Reason}}
			{{# }}}
		</script>
		<!--操作-->
		  <script type="text/html" id="barDemo">
		  		 <a class="layui-btn " lay-event="edit">登记</a>
		  </script>
	</body>
</html>
